﻿using System.Collections.Generic;
using Fetches.Fetch.Dto;
using Fetches.Fetch.Fetcher;
using Fetches.Fetch.Utils.FileHosting;

namespace Fetches.Custom.TestOrder
{
    public class WebMagicOrder : FetchOrder<HttpClientFetcher>
    {
        public static FetchOrder CreateForTest()
        {
            var prefix = "https://gitee.com/flashsword20/webmagic/";
            var packageLimit = "/master/webmagic-core/src/main/java/us/codecraft/webmagic/processor";
            var order = FetchOrder
                .Create("gitee_webmaic")
                .SetFetcherCount(1)
                .AddSeedUrls(new List<string> { $"{prefix}tree{packageLimit}" })
                .AddIndexPattern($@"{prefix}tree{packageLimit}/.+")
                .AddContentPattern($@"{prefix}blob/.+processor.+java$")
                .EnableProxy("127.0.0.1:1080")
                .EnableFileHosting(new[] { FileType.Image, FileType.Text });

            //警告：这个属性正常应该是由工厂类设置的
            order.FetcherTypeName = typeof(HttpClientFetcher).FullName;

            return order;
        }
    }
}
